<template>
  <view class="loading-empty f fd-col jc-c ai-c">
    <image
      src="/static/image/common/content_empty.png"
      mode="widthFix"
      style="width: 80rpx"
    ></image>
    <text class="mt20 mb20 color999">{{ tip }}</text>
    <van-button type="primary" round v-if="showButton" @click="click">{{
      buttonText
    }}</van-button>
  </view>
</template>

<script>
import { toRefs } from "vue";
export default {
  name: "loading-empty",
  props: {
    tip: String,
    url: String,
    buttonText: String,
    showButton: {
      type: Boolean,
      default: true,
    },
    toSwitchTab: {
      type: Boolean,
      default: false,
    },
  },
  setup(props) {
    const { url, toSwitchTab } = toRefs(props);
    const click = () => {
      if (!toSwitchTab.value) {
        uni.navigateTo({
          url: url.value,
        });
      } else {
        uni.switchTab({
          url: url.value,
        });
      }
    };
    return { click };
  },
};
</script>
<style lang='scss' scoped>
.loading-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>